Skip to content

Avoid ^ for exponentiation #18634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 22, 2022
Merged

Avoid ^ for exponentiation #18634

merged 5 commits into from
Jul 22, 2022

Conversation

iugo
Copy link
Contributor

@iugo iugo commented Jul 22, 2022

Summary

Use ** instead of ^.

Motivation

To avoid confusion with XOR.

Supporting details

Related issues

Metadata

  • Adds a new document
  • Rewrites (or significantly expands) a document
  • Fixes a typo, bug, or other error

To avoid confusion with XOR.
@iugo iugo requested a review from a team as a code owner July 22, 2022 07:27
@iugo iugo requested review from Josh-Cena and removed request for a team July 22, 2022 07:27
@github-actions github-actions bot added the Content:JS JavaScript docs label Jul 22, 2022
@teoli2003
Copy link
Contributor

So for a long time, JS had only pow() and no exponentiation operator. Using ^ wasn't really problematic.

I'm torn on this one.

What do you think, @Josh-Cena ? Should we ask this in a discussion to have more opinions? This will definitively have an impact on numerous other places on MDN.

@Josh-Cena
Copy link
Member

Josh-Cena commented Jul 22, 2022

What about using Math ML, or use a simple <sup>? I think ** is less readable and it's not meant to be code here anyway, so I think we should definitely remove the backticks. But I agree we shouldn't use ^ and I also tried to avoid this in the past.

@teoli2003
Copy link
Contributor

I think we should:

  1. if it is not code but an explanation, do not have back-ticks and use <sup>;
  2. if it is code, use **.

So avoid ^ and ** outside code.

I think we are in case 1 here.

@iugo
Copy link
Contributor Author

iugo commented Jul 22, 2022

I'm asking this question because the ^ symbol has two completely different meanings in math and programming.

https://stackoverflow.com/questions/4843304/why-is-my-power-operator-not-working

Hopefully there is a better way to avoid this ambiguity.

…_safe_integer/index.md

Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>
@Josh-Cena
Copy link
Member

I think it should be a one-time effort to fix it everywhere. We have about 20 pages with this issue. I'm going to commit to this branch.

@teoli2003
Copy link
Contributor

(I think MathML is a bit overkill for this, at least for the time being).

…_safe_integer/index.md

Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>
@Josh-Cena Josh-Cena changed the title Use ** instead of ^ Avoid ^ for exponentiation Jul 22, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jul 22, 2022

Preview URLs

Flaws

Note! 19 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/JavaScript/Data_structures
Title: JavaScript data types and data structures
on GitHub
Flaw count: 3

  • macros:
    • wrong xref macro used (consider changing which macro you use)
    • wrong xref macro used (consider changing which macro you use)
  • broken_links:
    • Can't resolve /en-US/docs/Glossary/Symbol

External URLs

URL: /en-US/docs/Web/JavaScript/Guide/Numbers_and_dates
Title: Numbers and dates
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Guide/Indexed_collections
Title: Indexed collections
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Typed_arrays
Title: JavaScript typed arrays
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Data_structures
Title: JavaScript data types and data structures
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_NOT
Title: Bitwise NOT (~)
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
Title: TypedArray
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Math
Title: Math
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow
Title: Math.pow()
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
Title: Math.trunc()
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp
Title: Math.exp()
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1
Title: Math.expm1()
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length
Title: String length
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
Title: parseInt()
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Number
Title: Number
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger
Title: Number.isSafeInteger()
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON
Title: Number.EPSILON
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER
Title: Number.MIN_SAFE_INTEGER
on GitHub


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE
Title: Number.MAX_VALUE
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
Title: Number.MAX_SAFE_INTEGER
on GitHub


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE
Title: Number.MIN_VALUE
on GitHub

No new external URLs

(this comment was updated 2022-07-22 08:06:56.097474)

@Josh-Cena
Copy link
Member

I realized we have this guide, though: https://developer.mozilla.org/en-US/docs/MDN/Contribute/Markdown_in_MDN#superscript_and_subscript We should reconsider that suggestion.

@Josh-Cena Josh-Cena requested a review from teoli2003 July 22, 2022 08:34
Copy link
Contributor

@teoli2003 teoli2003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go like this 😃

@teoli2003 teoli2003 merged commit 2e2eab5 into mdn:main Jul 22, 2022
@iugo iugo deleted the patch-1 branch July 26, 2022 10:18
@iugo
Copy link
Contributor Author

iugo commented Jul 26, 2022

I noticed some previous related discussions. #4578 (comment)


Maybe should remove particular for exponentiation.

@teoli2003
Copy link
Contributor

Yes, that discussion happened when we moved to Markdown last year. Before we stored our pages in HTML.

We tried to minimize the use of HTML tags.

We decided to keep the <sup> tag when useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:JS JavaScript docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants